perm filename A69.TEX[106,PHY] blob sn#807774 filedate 1985-10-07 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	\magnification\magstephalf
C00006 ENDMK
CāŠ—;
\magnification\magstephalf
\input macro.tex
\def\today{\ifcase\month\or
  January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or December\fi
  \space\number\day, \number\year}
\baselineskip 14pt
\rm
\line{\sevenrm a69.tex[106,phy] \today\hfill}

\bigskip
\line{\tt DIV {\rm  and} MOD\hfill}

If we have {\tt A} objects which we arrange into piles of size~{\tt B}, with
a possible pile of leftovers, the number of piles is the largest
integer in {\tt A/B}; this number is called, in Pascal, {\tt A DIV B}.
Since \hbox{{\tt B*(A DIV B)}} of the objects go into full piles, the number of
leftovers is {\tt A-B*(A DIV B)}, called, in Pascal, {\tt A MOD B}.

\medskip\noindent
{\bf Examples:}

\smallskip\disleft 25pt:(1):
We cut shelves of length {\tt B} from a plank of length~{\tt A}. The number
of shelves we can cut is \hbox{\tt A DIV B}; the length of the scrap piece
is {\tt A MOD B}.

\smallskip\disleft 25pt:(2):
A program prints {\tt A} numbers; there is room for {\tt B} of them on each
line. The number of full lines of output is {\tt A DIV B}, with
{\tt A MOD B} extra numbers on the last line. 
The number of lines in which there is printing is the number of lines
that would be filled completely if {\tt B-1} more numbers were printed,
which is \hbox{\tt (A+B-1) DIV B}.

{\rmn
{\narrower\smallskip\noindent
{\bf Drill:} Find a Pascal expression for the number of lines which
have a number in the third column.
\smallskip}

{\rmn
{\narrower\smallskip\noindent
[{\bf Solution:} The number of lines that would be filled completely if
{\tt B-3} more numbers were printed, or {\tt (A+B-3) DIV B}.]
\smallskip}
}

{\rmn
{\narrower\smallskip\noindent
{\bf Drill:} Find a Pascal expression which is 1 if there is a partially
filled line, and 0~if not.
\smallskip}
}

{\rmn
{\narrower\smallskip\noindent
[{\bf Solution:} If the last line is full, adding one to {\tt A} increases 
the number of lines. One formula is {\tt 1+(A-1) DIV B-A DIV B}.]
\smallskip}
}


\bigskip
\parindent0pt
\copyright 1984 Robert W. Floyd

First draft November 14, 1984

\bye